home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / batchut / bcsrce2.zip / BATREAD.SRC < prev    next >
Text File  |  1990-11-21  |  9KB  |  206 lines

  1. echo off
  2. rem ECHO %0 includes full file name such (Drive:\Dir\Sub\BATREAD.COM) in
  3. rem ECHO all uppercase.
  4. rem ********************************************************************
  5. rem Trap for a 'help' parameter. Use of ? or /? doesn't work.
  6. FOR %%H IN (help Help HELP /h /H) DO IF %1==%%H GOTO HELP
  7. rem ********************************************************************
  8. rem BATREAD, example, by Felix A. Rozewicz. All rights and responsibilities
  9. rem for this program are vacated by myself.
  10. rem This program is an example of how to use BAT2EXEC to do one of two
  11. rem actions:  1) pause after each screen's worth of echos, 2) echo
  12. rem continuously.
  13. rem ********************************************************************
  14. GOTO TOP
  15. :TOP
  16. rem *** If no parameter, at all, create environment variable '_' = '2'.
  17. IF !%1==! SET _=2
  18. IF !%1==! GOTO LABEL1
  19. rem *** If any parameter, at all, create environment variable '_' = 'A'.
  20. rem *** 'A' stands for VIEW ALL.
  21. SET _=A
  22. GOTO LABEL1
  23. :LABEL1
  24. IF %_%==2 cls
  25. echo BAT2EXEC
  26. echo  
  27. echo Doug Boling  -  Volume 9, Issue 14  -    August 1990
  28. echo  
  29. echo Purpose:  Compile your batch files for added speed. Large batch
  30. echo           files often run annoyingly slowly.  Compiling them with
  31. echo           BAT2EXEC will increase both your productivity and satisfaction.
  32. echo  
  33. echo  
  34. echo Daily PC operations are almost unimaginable without the use of batch
  35. echo files.  Everyone has his favorite collection of them, and some users
  36. echo have constructed complex batch files of thousands of bytes that push
  37. echo the batch langauge itself to its limits.  Programs that expand the
  38. echo available batch file functions, such as Michael Mefford's BATCHMAN,
  39. echo encourage users to make even larger batch files.
  40. echo  
  41. echo Unfortunately, however, batch files are also notoriously slow.
  42. echo It can be almost painful to watch them scroll down the screen a line
  43. echo at a time.  A standard way to improve the speed of interpreted
  44. echo programs, such as batch files, is to compile them.  That's where
  45. echo BAT2EXEC comes in.
  46. echo  
  47. IF %_%==2 PAUSE
  48. IF %_%==2 CLS
  49. GOTO LABEL2
  50. :LABEL2
  51. echo USING BAT2EXEC
  52. echo  
  53. echo The full syntax for BAT2EXEC could hardly be simpler.  Just enter:
  54. echo  
  55. echo      BAT2EXEC FILE.BAT
  56. echo  
  57. echo where FILE.BAT is the name of your batch file.  BAT2EXEC will then
  58. echo produce an executable .COM file with the name FILE.COM.  If BAT2EXEC
  59. echo can't find the batch file, an error message will be printed.  If
  60. echo BAT2EXEC can't understand a line in the batch file, it will print an
  61. echo error message indicating the line in the file in which it discovered
  62. echo the error.
  63. echo  
  64. echo BAT2EXEC should not be used on every batch file.  AUTOEXEC.BAT, for
  65. echo example, must remain a genuine batch file in order for COMMAND.COM to
  66. echo find it.  Similarly, batch files that run terminate and stay resident
  67. echo utilities (TSRs) should not be compiled.  The reason for this
  68. echo limitation lies in the DOS memory management structure:  if a TSR is
  69. echo executed from a program compiled by BAT2EXEC, the memory used by
  70. echo BAT2EXEC itself will not be made available to the system after
  71. echo it terminates.
  72. IF %_%==2 PAUSE
  73. IF %_%==2 CLS
  74. GOTO LABEL3
  75. :LABEL3
  76. echo  
  77. echo Programs created by BAT2EXEC behave slightly differently from the
  78. echo batch files from which they were compiled.  The .COM file does not
  79. echo echo each line to the screen as does the batch file, for example.
  80. echo Running other batch files does not cause the .COM program to end.
  81. echo Also, pressing Ctrl-Break does not present the message, "Terminate
  82. echo Batch file (y/n)."  If Ctrl-Break is pressed and BREAK has been set
  83. echo on, the program simply terminates.
  84. echo  
  85. echo The size of the resulting .COM file is somewhat larger than
  86. echo the batch file.  Compiling a batch file containing a single REM
  87. echo statement results in a .COM file size of 68 bytes, illustrating the
  88. echo overhead of the setup and terminate routines.  Program size increases
  89. echo quickly as routines are added then slows as the loaded routines are
  90. echo reused instead of new ones being added.
  91. echo  
  92. echo Certainly, BAT2EXEC is not suitable for use on every batch
  93. echo file.  Two and three line batch files are best left in their easy-to-
  94. echo alter and simple-to-understand ASCII format.  However, for those batch
  95. echo files that have grown into long complex programs, BAT2EXEC is the
  96. echo answer.
  97. IF %_%==2 PAUSE
  98. IF %_%==2 CLS
  99. rem *** Here we cut off from the continuous option. If '_' = 'A', we
  100. rem *** terminate the program. In effect, you can recreate the original
  101. rem *** BAT2EXEC.DOC in this manner. This is true for LABEL4-LABEL7.
  102. IF %_%==A GOTO END
  103. GOTO LABEL4
  104. :LABEL4
  105. echo In the (recent) past, I have, justifiably, criticized PC Magazine's
  106. echo BAT2EXEC.COM program. The revised, version 1.2, program is no longer
  107. echo so problematic. Douglas Boling got it, nearly, right this time. He
  108. echo has fixed the crippling problem of not supporting redirection. While
  109. echo it doesn't replace a sturdy utility like BATCOM or Power Batch, there
  110. echo are some types of .BAT programs that it is VERY useful for.
  111. echo                                 .
  112. echo If you have a .BAT that consists, predominately, of sections like
  113. echo the below, it can be indispensible:
  114. echo :MARK
  115. echo ECHO SYNTAX--:  MARK [TSR NAME]
  116. echo ECHO USAGE---:  Marks current memory state to later RELEASE named TSR
  117. echo ECHO SAMPLE SEQUENCE:    MARK SIDEKICK
  118. echo ECHO                     SIDEKICK
  119. echo ECHO                     {series of commands, etcetera}
  120. echo ECHO                     RELEASE SIDEKICK
  121. echo ECHO WARNING: MARKed TSR's MUST be RELEASEd in reverse order ALWAYS.
  122. echo ECHO Note:  MARK uses more memory than FMARK, but is more powerful.
  123. echo ECHO        [TSR NAME] is purely optional.
  124. echo ECHO TSR= Terminate Stay Resident
  125. echo GOTO END
  126. IF %_%==2 PAUSE
  127. IF %_%==2 CLS
  128. IF %_%==A GOTO END
  129. GOTO LABEL5
  130. :LABEL5
  131. echo                                 .
  132. echo BAT2EXEC, 1.2, writes to STDOUT. Therefor, you can redirect ECHOs
  133. echo to NUL, File, CON, PRN, LPT1, etcetera. The speed of finding a
  134. echo label is quite acceptable.
  135. echo                                 .
  136. echo To maximize an online help, as the above example illustrates, you
  137. echo can use a sequence like this:
  138. echo     BAT2EXEC Syntax.BAT
  139. echo     COMTOEXE Syntax
  140. echo     LZEXE Syntax
  141. echo     ERASE Syntax.COM
  142. echo     ERASE Syntax.OLD
  143. echo This will, effectively, cut the file size in half. This can be quite
  144. echo vital in a system without a hard drive (Laptop, dual floppy).
  145. echo                                 .
  146. IF %_%==2 PAUSE
  147. IF %_%==2 CLS
  148. IF %_%==A GOTO END
  149. GOTO LABEL6
  150. :LABEL6
  151. echo There are some alterations to, usual, BAT programming techniques that
  152. echo should be made. Foremost, is the practice of following ECHO with a
  153. echo single character, no space (ECHO., ECHO/, ECHO\) to achieve a blank
  154. echo line. All of these should be rewrittened to ECHO, one space, plus
  155. echo ASCII character 255. Also, BAT2EXEC is not forgiving of sloppy code.
  156. echo If you have two labels with the same name, a .COM file will not be
  157. echo compiled. This is also true if you have a GOTO Labelname but Label-
  158. echo name doesn't exist.
  159. echo                                 .
  160. echo If it stumbles on something like GOTO END, try doing a global replace
  161. echo on all ENDs to STOP (and vice-a-versa). Strangely, I have had this
  162. echo problem show up.
  163. echo                                 .
  164. echo In effect, you could use BAT2EXE as a debugging tool since it does
  165. echo give you some error messages. Not bad for 6.125K disk storage.
  166. echo                                 .
  167. IF %_%==2 PAUSE
  168. IF %_%==2 CLS
  169. IF %_%==A GOTO END
  170. GOTO LABEL7
  171. :LABEL7
  172. echo Some uses that come to immediate mind would be a consolidation of
  173. echo single screen reference files previously made with MAKECOM.BAS:
  174. echo   1) Postal State Abreviations
  175. echo   2) Printer codes for a specific printer
  176. echo   3) ANSI.SYS commands
  177. echo   4) The extended IBM character sets
  178. echo   5) dBASE INKEY/READKEY/ON LABEL lists
  179. echo By doing this, you can